﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity.Infrastructure;
using System.ComponentModel.DataAnnotations;
using Entity;

namespace Utl
{
    public class DB : DbContext
    {
        public DbSet<Entity.Workflow> ExpLevels { get; set; }
        public DbSet<WorkflowType> SalesTypes { get; set; }
        public DbSet<Company> Companys { get; set; }
        public DbSet<Field> Fields { get; set; }
        public DbSet<Activity> Activitys { get; set; }
        public DbSet<ActivityType> ActivityTypes { get; set; }
        //public DbSet<Role> Roles { get; set; }
        //public DbSet<Area> Areas { get; set; }
        //public DbSet<Category> Categorys { get; set; }
        //public DbSet<LeadCall> LeadCalls { get; set; }
        //public DbSet<Research> Researchs { get; set; }
        //public DbSet<PackageType> PackageTypes { get; set; }
        //public DbSet<ParticipantType> ParticipantTypes { get; set; }
        //public DbSet<PhoneSaleSupport> OnPhoneTemplates { get; set; }
        //public DbSet<OnPhoneBlockType> OnPhoneBlockTypes { get; set; }
        //public DbSet<LeadCallType> LeadCallTypes { get; set; }
        //public DbSet<CurrencyType> CurrencyTypes { get; set; }
        //public DbSet<PackageItem> PackageItems { get; set; }
        //public DbSet<Package> Packages { get; set; }
        //public DbSet<FAQ> FAQs { get; set; }
        //public DbSet<PaymentType> PaymentTypes { get; set; }
        //public DbSet<TargetOfMonth> TargetOfMonths { get; set; }
        //public DbSet<TargetOfWeek> TargetOfWeeks { get; set; }
        //public DbSet<DistrictNumber> DistrictNumbers { get; set; }
        //public DbSet<Member> Members { get; set; }
        //public DbSet<Deal> Deals { get; set; }
        //public DbSet<Project> Projects { get; set; }
        //public DbSet<Department> Departments { get; set; }
        //public DbSet<Message> Messages { get; set; }
        //public DbSet<Image> Images { get; set; }
        //public DbSet<CompanyRelationship> CompanyRelationships { get; set; }

        public DB()
        {
           Database.SetInitializer<DB>(new DBInitializer());
          //Database.SetInitializer<DB>(null);
           


            this.Configuration.ValidateOnSaveEnabled = false;
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }


    }

    public class DBInitializer : DropCreateDatabaseIfModelChanges<DB>
    {
        protected override void Seed(DB context)
        {
            FakeData(context);
            context.SaveChanges();
        }

        private void FakeData(DB context)
        {
          
        }
    }

}